<template>
<div class="basic-setting-content pl16 pr16">
    <div class="common-form">{{$t('setting.merchant_entry_settings')}}</div>
    <el-form-item :label="$t('setting.enable_sms_verification')">
      <div>
        <el-radio v-model="form.smsOpen" :label="1">{{$t('setting.turn_on')}}</el-radio>
        <el-radio v-model="form.smsOpen" :label="0">{{$t('setting.turn_off')}}</el-radio>
      </div>
    </el-form-item>
    <div class="common-form">{{$t('setting.platform_operations_settings')}}</div>
    <el-form-item
      :label="$t('setting.commission_percentage')"
      :rules="[{  required: true,  message: ' '}]"
      prop="commissionRate"
    >
      <el-input
        v-model.trim="form.commissionRate"
        :placeholder="$t('setting.sampling_ratio')"
        class="max-w460"
        type="number"
        @keyup.native="renumber($event)"
      ></el-input>
    </el-form-item>
    <el-form-item :label="$t('setting.product_add_audit')">
      <div>
        <el-radio v-model="form.addAudit" :label="1">{{$t('setting.yes')}}</el-radio>
        <el-radio v-model="form.addAudit" :label="0">{{$t('setting.no')}}</el-radio>
      </div>
    </el-form-item>
    <el-form-item :label="$t('setting.product_edit_audit')">
      <div>
        <el-radio v-model="form.editAudit" :label="1">{{$t('setting.yes')}}</el-radio>
        <el-radio v-model="form.editAudit" :label="0">{{$t('setting.no')}}</el-radio>
      </div>
    </el-form-item>
    <div class="common-form">{{$t('setting.merchant_image_bg')}}</div>
    <el-form-item
      :label="$t('setting.merchant_entry_bg')"
      :rules="[{  required: true,  message: $t('setting.input_merchant_entry_image')}]"
    >
      <div class="ww100">
        <el-button @click="chooseImg('image')">{{$t('setting.select_image')}}</el-button>
      </div>
      <img class="mt10" v-img-url="form.supplierImage" :width="200" />
      <div class="gray9">{{$t('setting.merchant_entry_image_tip')}}</div>
    </el-form-item>
    <!--上传图片-->
    <Upload
      v-if="isupload"
      :isupload="isupload"
      :type="type"
      :config="{  total: 1}"
      @returnImgs="returnImgsFunc"
    >
    </Upload>
  </div>
</template>

<script>
import Upload from "@/components/file/Upload.vue";
export default {
  components: {
    Upload
  },
  data() {
    return {
      /*是否打开图片选择*/
      isupload: false,
      type: ""
    };
  },
  inject: ["form"],
  created() {},
  methods: {
    renumber(e) {
      var keynum = window.event ? e.keyCode : e.which;
      var keycar = String.fromCharCode(keynum);
      if (keynum == 189 || keynum == 190 || keynum == 110 || keynum == 109) {
        this.$message.warning($t("setting.no_decimal_negative"));
        e.target.value = "";
      }
    },
    /*选择图片*/
    chooseImg(e) {
      this.type = e;
      this.isupload = true;
    },
    /*关闭选择图片*/
    returnImgsFunc(e) {
      this.isupload = false;
      if (e != null && e.length > 0) {
        if (this.type == "image") {
          this.form.supplierImage = e[0].filePath;
        }
      }
    }
  }
};
</script>

<style lang="scss" scoped>
.addCustom_content {
  margin-top: 20px;

  .custom_box {
    margin-bottom: 10px;
  }
}

.addCustomBox {
  margin-top: 12px;
  font-size: 13px;
  font-weight: 400;
  color: var(--prev-color-primary);

  .btn {
    cursor: pointer;
    width: max-content;
    background-color: rgba(64, 149, 229, 1);
    color: rgba(255, 255, 255, 1);
  }
}

.titTip {
  display: inline-bolck;
  font-size: 12px;
  line-height: 24px;
  font-weight: 400;
  color: #999999;
}

.addfont {
  display: inline-block;
  font-size: 12px;
  font-weight: 400;
  color: #4095e5;
  margin-left: 14px;
  cursor: pointer;
}
</style>

